struct ListNode* detectCycle(struct ListNode* head) {
    struct ListNode* fast, * slow;
    fast = slow = head;
    struct ListNode* temp = head;
    while (fast)
    {

        fast = fast->next;
        if (fast)
        {
            fast = fast->next;
            slow = slow->next;
        }
        if (fast == slow)
        {
            break;
        }
    }
    if (fast == NULL)
        return NULL;
    else
    {
        while (1)
        {
            if (temp == slow)
                return slow;
            temp = temp->next;
            slow = slow->next;

        }
    }
}